package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * 交付记录表
 */
@Entity
@Table(name = "del_record", schema = "lxh_crm")
public class DelRecord {
    private int delRecordId;
    private Date delDate;
    private String remark;
    /** 关联交付计划 */
    private DeliveryPlan deliveryPlan;
    /** 我方负责人，为一个员工对象 */
    private Emp ourDel;
    /** 对方负责人即客户联系人中的一个 */
    private Contact otherTake;

    @ManyToOne
    @JoinColumn(name = "other_take")
    public Contact getOtherTake() {
        return otherTake;
    }

    public void setOtherTake(Contact otherTake) {
        this.otherTake = otherTake;
    }

    @ManyToOne
    @JoinColumn(name = "delivery_plan_id")
    public DeliveryPlan getDeliveryPlan() {
        return deliveryPlan;
    }

    public void setDeliveryPlan(DeliveryPlan deliveryPlan) {
        this.deliveryPlan = deliveryPlan;
    }

    @ManyToOne
    @JoinColumn(name = "our_del")
    public Emp getOurDel() {
        return ourDel;
    }

    public void setOurDel(Emp ourDel) {
        this.ourDel = ourDel;
    }

    @Id
    @Column(name = "del_record_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getDelRecordId() {
        return delRecordId;
    }

    public void setDelRecordId(int delRecordId) {
        this.delRecordId = delRecordId;
    }


    @Basic
    @Column(name = "del_date", nullable = true)
    public Date getDelDate() {
        return delDate;
    }

    public void setDelDate(Date delDate) {
        this.delDate = delDate;
    }


    @Basic
    @Column(name = "remark", nullable = true, length = 200)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DelRecord delRecord = (DelRecord) o;
        return delRecordId == delRecord.delRecordId &&
                Objects.equals(delDate, delRecord.delDate) &&
                Objects.equals(otherTake, delRecord.otherTake) &&
                Objects.equals(ourDel, delRecord.ourDel) &&
                Objects.equals(remark, delRecord.remark) &&
                Objects.equals(deliveryPlan, delRecord.deliveryPlan);
    }

    @Override
    public int hashCode() {
        return Objects.hash(delRecordId, delDate, otherTake, ourDel, remark, deliveryPlan);
    }

    @Override
    public String toString() {
        return "DelRecord{" +
                "delRecordId=" + delRecordId +
                ", delDate=" + delDate +
                ", otherTake='" + otherTake + '\'' +
                ", ourDel='" + ourDel + '\'' +
                ", remark='" + remark + '\'' +
                ", deliveryPlan=" + deliveryPlan +
                '}';
    }
}
